<?php

    class LoginMutex {
    
        private static $LOGIN_MTX_NID = 0xff4321;
        
        static private $_semaphore = NULL;
        
        private function __construct() {
        }
        
        public static function initialize() {
            self::$_semaphore = sem_get(self::$LOGIN_MTX_NID);
        }
    
        public static function acquireLoginSession() {
            if (self::$_semaphore == NULL) self::initialize();
            return sem_acquire(self::$_semaphore);
        }
        
        public static function releaseLoginSession() {
            return sem_release(self::$_semaphore);
        }
        
        /* public static function getInstance()
        {
            if (self::$instance == NULL) {
                self::$instance = new LoginMutex();
            }
            return self::$instance;
        }  */      
        
        private function __clone() {
        }
    
    }

?>
